﻿Imports System.Data.SqlClient
Public Class clsOrdenCompra

  Private cnDB As SqlConnection

  Public Sub New(ByVal psConnectString As String)
    cnDB = New SqlConnection(psConnectString)
  End Sub

  Public Function OrdenCompraListar() As DataTable
    Dim sqlCmd As New SqlClient.SqlCommand
    Dim oSqlda As SqlDataAdapter
    Dim oDataTable As New DataTable
    Try
      sqlCmd.Connection = cnDB
      sqlCmd.CommandType = CommandType.StoredProcedure
      sqlCmd.CommandText = "spOrdenCompraListar"
      cnDB.Open()

      oSqlda = New SqlDataAdapter(sqlCmd)
      oSqlda.Fill(oDataTable)
      oSqlda.Dispose()
      sqlCmd.Dispose()

      Return oDataTable

    Catch ex As Exception
      Throw
    Finally
      If cnDB.State = ConnectionState.Open Then cnDB.Close()
    End Try
  End Function
End Class
